import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useFakeAuth } from '../contexts/FakeAuthContext';

function ProtectedRoute({ children }) {
  const { isAuthenticated } = useFakeAuth();
  const navigate = useNavigate();

  useEffect(() => {
    if (!isAuthenticated) {
      navigate('/login');
    }
  }),
    [isAuthenticated, navigate];

  return children;
}

export default ProtectedRoute;
